﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BDS3M.Admin.Controls
{
    public partial class EditTinhThanhPho : System.Web.UI.UserControl
    {
        DataTable dt;
        public string name;
        public int id;
        protected void Page_Load(object sender, EventArgs e)
        {
            id = Convert.ToInt32(Request.QueryString["id"]);
            dt = DAL.DCollector.DBCollector.Instance.StoredSelectAllTableWhereID("tbl_TinhThanhPho", "TinhThanhPho_ID", id.ToString());
            name = dt.Rows[0]["TinhThanhPho_Ten"].ToString();
            txtName.Text = name;
        }

        protected void btnUpdateSlide_Click(object sender, EventArgs e)
        {
            if (name != "")
            {

                DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];
                cl[0] = new DAL.DHelpers.Column("TinhThanhPho_Ten", txtName.Text, DAL.DHelpers.DataType.DataTypeSql.Nvarchar);
                string[] colWhere = new string[1];
                colWhere[0] = "TinhThanhPho_ID";

                object[] colValue = new object[1];
                colValue[0] = id;

                DAL.DCollector.DBCollector.Instance.Update("tbl_TinhThanhPho", cl, colWhere, colValue);
                Response.Redirect("/Admin/Index.aspx?panel=1&sub=9");
            }
            else
            {
                Response.Write("<script>alert('Không thể để tên trống");
            }
        }
    }
}